import { serverUrl } from "./request";
import moment from "moment";

//图片处理
export const dalImg = (url) => {
  if (url) {
    if (url.startsWith("http")) {
      return url;
    }
    return serverUrl + url;
  }
  return "https://img2.baidu.com/it/u=2890830300,1721859624&fm=253&fmt=auto&app=120&f=JPEG?w=750&h=500";
};

//判断是否签到
export const checkedToday = () => {
  const today = moment().format("YYYY-MM-DD");
  const localDate = localStorage.getItem("check-data");
  if (localDate) {
    if (localDate == today) {
      return true;
    }
    localStorage.setItem("check-data", today);
    return false;
  } else {
    localStorage.setItem("check-data", today);
    return false;
  }
};
